package cn.stylefeng.guns.modular.business.frequency.modifyrecord.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.modifyrecord.service.ModifyRecordService;
import cn.stylefeng.guns.modular.business.frequency.modifyrecord.model.param.ModifyRecordParam;

import javax.annotation.Resource;

/**
 * 修改记录 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class ModifyRecordController {

    @Resource
    private ModifyRecordService modifyRecordService;

    /**
     * 分页查询修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/modifyRecord/page")
    @BusinessLog(title = "修改记录_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(ModifyRecordParam modifyRecordParam) {
        return new SuccessResponseData(modifyRecordService.page(modifyRecordParam));
    }

    /**
     * 获取全部修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/modifyRecord/list")
    @BusinessLog(title = "修改记录_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(ModifyRecordParam modifyRecordParam) {
        return new SuccessResponseData(modifyRecordService.list(modifyRecordParam));
    }

    /**
     * 查看详情修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/modifyRecord/detail")
    @BusinessLog(title = "修改记录_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(ModifyRecordParam.detail.class) ModifyRecordParam modifyRecordParam) {
        return new SuccessResponseData(modifyRecordService.detail(modifyRecordParam));
    }

    /**
     * 添加修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/modifyRecord/add")
    @BusinessLog(title = "修改记录_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(ModifyRecordParam.add.class) ModifyRecordParam modifyRecordParam) {
        modifyRecordService.add(modifyRecordParam);
        return new SuccessResponseData();
    }

    /**
     * 删除修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/modifyRecord/delete")
    @BusinessLog(title = "修改记录_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(ModifyRecordParam.delete.class) ModifyRecordParam modifyRecordParam) {
        modifyRecordService.delete(modifyRecordParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑修改记录
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/modifyRecord/edit")
    @BusinessLog(title = "修改记录_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(ModifyRecordParam.edit.class) ModifyRecordParam modifyRecordParam) {
        modifyRecordService.edit(modifyRecordParam);
        return new SuccessResponseData();
    }


}
